package training;

import java.util.HashMap;
import java.util.HashSet;

/**
 * @Author liangzai
 * @Description:
 */
public class J_test_25_7_22 {
    public int maximumUniqueSubarray(int[] nums) {
        if(nums.length == 0){
            return 0;
        }
        int max = 0;
        for (int i = 0; i < nums.length; i++) {
            HashSet<Integer> set = new HashSet<>();
            int sum = 0;
            for (int j = i; j < nums.length; j++) {
                if(!set.contains(nums[j])) {
                    sum += nums[j];
                    set.add(nums[j]);
                    max = Math.max(max,sum);
                }else {
                    i = j;
                    break;
                }
            }
        }
        return max;
    }
}
